/**
 * com.chaeron.GPS - An API for access to GPS devices.
 *
 *
 * Copyright (c) 2001, 2002 Chaeron Corporation,
 * All rights reserved.
 * 
 * Chaeron grants you a non-exclusive license to use, modify and re-distribute
 * this program under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version, provided that this copyright notice and 
 * license appear on all copies of the software.
 * 
 * Software is provided "AS IS," without a warranty of any kind. ALL EXPRESS OR
 * IMPLIED REPRESENTATIONS AND WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF
 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE
 * HEREBY EXCLUDED. THE ENTIRE RISK ARISING OUT OF USING THE SOFTWARE IS ASSUMED
 * BY THE LICENSEE. See the GNU General Public License for more details.
 *
 * CHAERON AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY DAMAGES SUFFERED BY
 * LICENSEE OR ANY THIRD PARTY AS A RESULT OF USING OR DISTRIBUTING SOFTWARE.
 * IN NO EVENT WILL CHAERON OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE,
 * PROFIT OR DATA, OR FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL
 * OR PUNITIVE DAMAGES, HOWEVER CAUSED AN REGARDLESS OF THE THEORY OF LIABILITY,
 * ARISING OUT OF THE USE OF OR INABILITY TO USE SOFTWARE, EVEN IF CHAERON HAS
 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

* @version     1.02
* @author      Andrzej Jan Taramina, Chaeron Corporation
*              andrzej@chaeron.com
*/

package com.chaeron.GPS.Garmin;

//***************************************************************************
 //*
 //*     Imports
 //*
 //***************************************************************************/

import com.chaeron.GPS.*;
import com.chaeron.GPS.exception.*;


//***************************************************************************
 //*
 //*     AckGarminPacket Class definition
 //*
 //***************************************************************************/

/**
 * The AckGarminPacket class represents Ack Packets
 *
 */

public class AckGarminPacket extends GarminPacket
{
	//***************************************************************************
 	//*
 	//*     Constant definitions
 	//*
 	//***************************************************************************/
	
	//***************************************************************************
 	//*
 	//*     Attributes
 	//*
 	//***************************************************************************/
	
	//***************************************************************************
 	//*
 	//*     Constructors
 	//*
 	//***************************************************************************/
	
	/**
	 * Create a default AckGarminPacket instance
	 */
	
	public AckGarminPacket()
	{  
		super( Protocol.GARMIN_PID_ACK, new byte[] { 0, 0 }, 2 );
	}
	
	
	/**
	 * Create a AckGarminPacket from the given packet data
	 *
	 * @param	packet		packet data buffer
	 * @param	len			length of packet data
	 */
	
	AckGarminPacket( byte[] packet, int len )
	{  
		super( packet, len );
	}
	
	
	//***************************************************************************
 	//*
 	//*     Packet Processing Methods
 	//*
 	//***************************************************************************/
	
	/**
	 * Process the packet
	 *
	 * @param	gps			the GPS object that requested the packet to be processed
	 */
	
	void process( GPS gps )
	{
		// Do nothing
	}
	
	
	//***************************************************************************
 	//*
 	//*     Methods
 	//*
 	//***************************************************************************/
	
	/**
	 * Set ack to respond to given packet
	 *
	 * @param	packet		packet to respond to
	 */
	
	void setRespondToPacket( GarminPacket packet )
	{
		packetBuffer[ PACKET_DATA ] = packet.getPacketIDByte();
		setChecksum();
	}
	
	
	/**
	 * get packet ID being responded to
	 *
	 * @return			packet ID being responded to
	 */
	
	public byte getRespondToPacketIDByte()
	{
		return( packetBuffer[ PACKET_DATA ] );
	}
	
	
	/**
	 * get packet ID being responded to
	 *
	 * @return			packet ID being responded to
	 */
	
	public short getRespondToPacketID()
	{
		return( (short)( ( packetBuffer[ PACKET_DATA ] + 256 ) & 0xFF ) );
	}
	
	
}
